package com.aidex.biz.controller;

import com.aidex.common.utils.uuid.IdUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class JdTest {

    public static void main(String[] args) throws IOException {
        String url =
                "https://search.jd.com/Search?keyword=阿苯达唑片（肠虫清）0．2g＊10s中美史克&enc=utf-8&pvid=" + IdUtils.randomUUID();
        Document document =
                Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) " + "Gecko" + "/20070725 Firefox/2.0.0.6").get();
        Elements divs = document.getElementsByClass("p-name-type-2");
        for (Element element : divs) {
            Element a = element.child(0);
            System.out.println(a.attr("href") + "/" + a.text());
        }

    }
}
